var rootPath = getRootPath();

$(function() {
	
	var callbackUrl = getUrlParam("callbackUrl");//getUrlParam 带转义
	var param = "";
	if(callbackUrl){
		$("#back").css("display","unset");
		$("#back").click(function(){
			parent.document.location.href = callbackUrl;
		});
		param = "?callbackUrl=" +  encodeURIComponent(callbackUrl);
	}else{
		$("#back").css("display","none");
		param = "";
	}
	
	$.ajax({
		url : rootPath + "/userDetailFront/queryDetailInfo",
		method : "GET",
		success : function(data) {
			if(data.returnCode == '0000') {
				if(data.returnObject != null) {
					var obj = data.returnObject;
					if(obj.accountName != null && obj.accountName != ""){
						$("#accountName").text(obj.accountName);
					}
					if(obj.accountName != null && obj.accountName != ""){
						$("#bankAccount").text(obj.bankAccount);
					}
					if(obj.accountName != null && obj.accountName != ""){
						$("#depositBank").text(obj.depositBank);
					}
					if(obj.accountName != null && obj.accountName != ""){
						$("#aopenBranch").text(obj.aopenBranch);
					}
					if(obj.aopenProvince!=null && obj.aopenProvince!=""){
						getAreaInfo(obj.aopenProvince,"#aopenProvince");
					}
					if(obj.aopenCity!=null && obj.aopenCity!=""){
						getAreaInfo(obj.aopenCity,"#aopenCity");
					}
				}
			}else{
				layer.alert(data.returnMessage);
			}
		},
		error: function (jqXHR, textStatus, errorThrown) {
			layer.alert("error");
		}
	});
	
	$("#modify").click(function() {
		parent.$("#content").prop("src","bankInfo.html"+param);
	});
});

function getAreaInfo(areaId,id){
	if( !areaId || areaId == '' || !id || id == '' ){
		return;
	}
	$.ajax({
		url : rootPath + "/area/"+areaId,
		method : "GET",
		success : function(res) {
			if(res.returnCode == '0000') {
				 $(id).text(res.returnObject.title);
			}
		},
		error: function (jqXHR, textStatus, errorThrown) {
			console.error("get areaInfo error~~~!")
		}
	});
}